VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Salaries 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Salary Details"
   ClientHeight    =   11040
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   20310
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   11040
   ScaleWidth      =   20310
   WindowState     =   2  'Maximized
   Begin RichTextLib.RichTextBox RichTextBox2 
      Height          =   375
      Left            =   3000
      TabIndex        =   15
      Top             =   240
      Visible         =   0   'False
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   661
      _Version        =   393217
      TextRTF         =   $"Salary.frx":0000
   End
   Begin RichTextLib.RichTextBox RichTextBox1 
      Height          =   375
      Left            =   840
      TabIndex        =   14
      Top             =   120
      Visible         =   0   'False
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   661
      _Version        =   393217
      TextRTF         =   $"Salary.frx":0082
   End
   Begin VB.ComboBox Combo1 
      Height          =   315
      Left            =   17040
      TabIndex        =   0
      Top             =   840
      Width           =   2295
   End
   Begin VB.Frame Frame1 
      Appearance      =   0  'Flat
      ForeColor       =   &H80000008&
      Height          =   9135
      Left            =   960
      TabIndex        =   7
      Top             =   1200
      Width           =   18495
      Begin VB.CommandButton Command2 
         Caption         =   "TDS Report"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   16200
         TabIndex        =   21
         Top             =   8520
         Width           =   1215
      End
      Begin VB.ComboBox Text1 
         Height          =   315
         Left            =   3240
         TabIndex        =   16
         Top             =   720
         Width           =   1215
      End
      Begin VB.CommandButton Command8 
         Caption         =   "Finish"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   17520
         TabIndex        =   6
         Top             =   8520
         Width           =   855
      End
      Begin VB.CommandButton Command3 
         Caption         =   "Print"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   11520
         TabIndex        =   3
         Top             =   8520
         Width           =   1095
      End
      Begin VB.CommandButton Command4 
         Caption         =   "Print All"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   12960
         TabIndex        =   4
         Top             =   8520
         Width           =   1095
      End
      Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
         Height          =   6135
         Left            =   840
         TabIndex        =   8
         Top             =   2160
         Width           =   16455
         _ExtentX        =   29025
         _ExtentY        =   10821
         _Version        =   393216
         BackColor       =   -2147483634
         BackColorSel    =   -2147483634
         BackColorBkg    =   -2147483633
         BorderStyle     =   0
         Appearance      =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Microsoft Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.TextBox Text2 
         Appearance      =   0  'Flat
         Height          =   285
         Left            =   15840
         Locked          =   -1  'True
         TabIndex        =   9
         Top             =   1320
         Width           =   1815
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Get Salary"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   11280
         TabIndex        =   2
         Top             =   720
         Width           =   1575
      End
      Begin VB.ComboBox cbemp 
         Height          =   315
         Left            =   7800
         TabIndex        =   1
         Top             =   720
         Width           =   2295
      End
      Begin VB.CommandButton Command7 
         Caption         =   "Generate Report"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   14400
         TabIndex        =   5
         Top             =   8520
         Width           =   1695
      End
      Begin VB.Label Label6 
         Caption         =   "Label6"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5400
         TabIndex        =   20
         Top             =   1320
         Width           =   4215
      End
      Begin VB.Label Label1 
         Caption         =   "Label1"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   960
         TabIndex        =   19
         Top             =   1320
         Width           =   4215
      End
      Begin VB.Label Label2 
         Caption         =   "Select Employee"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   5400
         TabIndex        =   18
         Top             =   750
         Width           =   1455
      End
      Begin VB.Label Label4 
         Caption         =   "Select Month"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   1020
         TabIndex        =   17
         Top             =   750
         Width           =   1455
      End
      Begin VB.Label Label3 
         Caption         =   "Total Salary"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   14520
         TabIndex        =   10
         Top             =   1320
         Width           =   2175
      End
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   1440
      Top             =   8640
      Width           =   9615
      _ExtentX        =   16960
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Image Image1 
      Height          =   840
      Left            =   7080
      Picture         =   "Salary.frx":0104
      Stretch         =   -1  'True
      Top             =   0
      Width           =   960
   End
   Begin VB.Label Label5 
      Caption         =   "Select Year"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   15360
      TabIndex        =   13
      Top             =   840
      Width           =   1455
   End
   Begin VB.Label Label15 
      Caption         =   "JEEVAN VAISYA GREEN AGROTECH LLP"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   14.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   8160
      TabIndex        =   12
      Top             =   360
      Width           =   5895
   End
   Begin VB.Label Label16 
      Caption         =   "EMPLOYEES' SALARY DETAILS FORM"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   9420
      TabIndex        =   11
      Top             =   840
      Width           =   3375
   End
End
Attribute VB_Name = "Salaries"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim c As Connection
Dim d As Connection
Dim dbne As Connection
Dim r, r1 As Recordset
Dim rs1 As Recordset
Dim rs As Recordset
Dim rs2, rs3, rs4 As Recordset
Dim rs8 As Recordset
Dim rs9 As Recordset
Dim mon(12), s As String
Dim m, a(3) As Long
Dim les, col, tds As Currency
Dim bm As Currency
Dim b As Boolean
Dim var As String
Dim st1() As Variant
Dim inc As Integer
Dim r10 As Recordset
Dim cbdes As String
Dim totcol As Currency
Dim lesup As Boolean
Dim rs10 As Recordset
Dim repmon As String
Dim ad(10) As String
Dim pg As Recordset
Dim hideReport As Integer
Dim mbool As Boolean
Dim branch As String
Dim mscount As Integer


Private Sub cbemp_Click()
    branch = ""
    mscount = 1
    Command1.Enabled = True
End Sub

Private Sub Combo1_Click()
Call database
Frame1.Enabled = True
cbemp.Clear
Set rs = New Recordset
rs.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open "Select CodeNo from AgentInfo where Pos <> 'Agent' order by CodeNo", c
If Not rs.EOF Then
rs.MoveFirst
While Not rs.EOF
cbemp.AddItem (rs.Fields(0))
rs.MoveNext
Wend
End If
rs.Close
Text1.Clear
Text1.AddItem ("Jan")
Text1.AddItem ("Feb")
Text1.AddItem ("Mar")
Text1.AddItem ("Apr")
Text1.AddItem ("May")
Text1.AddItem ("Jun")
Text1.AddItem ("Jul")
Text1.AddItem ("Aug")
Text1.AddItem ("Sep")
Text1.AddItem ("Oct")
Text1.AddItem ("Nov")
Text1.AddItem ("Dec")
'cbdes.SetFocus
End Sub
Private Sub Command1_Click()
If branch = "" Then
    cbdes = ""
    Dim i, l As Integer
    a(0) = 0
    a(1) = 0
    a(2) = 0
    a(3) = 0
    bm = 0
    les = 0
    totcol = 0
    Text2 = 0
    MSFlexGrid1.Rows = 1
    MSFlexGrid1.Font.Size = 9
    Call database
    cbdes = designation(cbemp.Text)
    i = 1
Else
    a(0) = 0
    a(1) = 0
    a(2) = 0
    a(3) = 0
    i = mscount
End If

    If cbemp.Text <> "" And Text1 <> "" Then
        If branch = "" Then
            For clm = 0 To 9
            MSFlexGrid1.ColAlignment(clm) = 4
            Next
        End If
    If cbdes <> "DM" Then
    r1.Open "select CodeNo from agentinfo where IntroNo='" & cbemp.Text & "' or CodeNo='" & cbemp.Text & "'", c
    ElseIf cbdes = "DM" Then
    r1.Open "select CodeNo from agentinfo where IntroNo='" & cbemp.Text & "' or CodeNo='" & cbemp.Text & "'", c
    End If
l = 0
m = Val(Text1.ListIndex + 1)
If r1.EOF Then
'MsgBox "No Record Present"
Else
Set rs1 = New Recordset
rs1.CursorLocation = adUseServer
rs1.CursorType = adOpenKeyset
rs1.LockType = adLockOptimistic
'changed
rs1.Open "Select Less from Salary where CodeNo='" & cbemp.Text & "'", c
If rs1!Less <> "" And checktds Then bm = bm + Val(rs1!Less) 'store the less Amount in bm
r1.MoveFirst
While Not r1.EOF
rs1.Close
rs1.Open "select " & Text1.Text & 1 & "," & Text1.Text & 2 & "," & Text1.Text & 3 & "," & Text1.Text & 4 & ", Name, Pos, CodeNo, IntroCode, Less  from salary where CodeNo='" & r1.Fields(0) & "'", c
For l = 0 To 3
If Not (IsNull(rs1.Fields(l)) Or rs1.Fields(l) = "" Or rs1.Fields(l) = 0) Then
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
'MsgBox c
MSFlexGrid1.TextMatrix(i, 0) = i
MSFlexGrid1.TextMatrix(i, 1) = rs1.Fields(4)
MSFlexGrid1.TextMatrix(i, 2) = rs1.Fields(6)
MSFlexGrid1.TextMatrix(i, 3) = rs1.Fields(5)
MSFlexGrid1.TextMatrix(i, 4) = rs1.Fields(7)
MSFlexGrid1.TextMatrix(i, 5) = Switch(rs1.Fields(5) = "Agent", 1, rs1.Fields(5) = "DM", 2, rs1.Fields(5) = "ADM", 3, rs1.Fields(5) = "RDM", 4, rs1.Fields(5) = "DA", 5, rs1.Fields(5) = "DA-I", 6, rs1.Fields(5) = "DA-II", 7, rs1.Fields(5) = "DA-III", 8, rs1.Fields(5) = "CED", 9)
MSFlexGrid1.TextMatrix(i, 6) = Switch(l = 0, "I", l = 1, "II", l = 2, "III", l = 3, "Lump Sum")
'If rs1.Fields(l) <> 0 Then
MSFlexGrid1.TextMatrix(i, 7) = FormatCurrency(Switch(rs1.Fields(l) = "", 0, 1, rs1.Fields(l)), 2)
col = col + Val(rs1.Fields(l))
Call commi(l, rs1.Fields(5), Val(Switch(rs1.Fields(l) = "", 0, 1, rs1.Fields(l))))
MSFlexGrid1.TextMatrix(i, 8) = Switch(rs1.Fields(5) = "CED" And cbdes = "CED", 0, 1, percen(l, MSFlexGrid1.TextMatrix(i, 5)))
MSFlexGrid1.TextMatrix(i, 9) = FormatCurrency((Val(rs1.Fields(l)) * Val(MSFlexGrid1.TextMatrix(i, 8))) / 100)
'If Val(MSFlexGrid1.TextMatrix(i, 7)) < 0 Then MsgBox "Check Here"
'End If
i = i + 1
End If
Next
r1.MoveNext
Wend
rs1.Close
'MsgBox c
If mscount < MSFlexGrid1.Rows Then
    
    For i = mscount To MSFlexGrid1.Rows - 1
    If MSFlexGrid1.TextMatrix(i, 2) = cbemp.Text And MSFlexGrid1.TextMatrix(i, 6) = "I" Then
    MSFlexGrid1.TextMatrix(i, 7) = FormatCurrency(MSFlexGrid1.TextMatrix(i, 7) - a(0), 2)
    ElseIf MSFlexGrid1.TextMatrix(i, 2) = cbemp.Text And MSFlexGrid1.TextMatrix(i, 6) = "II" Then
    MSFlexGrid1.TextMatrix(i, 7) = FormatCurrency(MSFlexGrid1.TextMatrix(i, 7) - a(1), 2)
    ElseIf MSFlexGrid1.TextMatrix(i, 2) = cbemp.Text And MSFlexGrid1.TextMatrix(i, 6) = "III" Then
    MSFlexGrid1.TextMatrix(i, 7) = FormatCurrency(MSFlexGrid1.TextMatrix(i, 7) - a(2), 2)
    ElseIf MSFlexGrid1.TextMatrix(i, 2) = cbemp.Text And MSFlexGrid1.TextMatrix(i, 6) = "Lump Sum" Then
    MSFlexGrid1.TextMatrix(i, 7) = FormatCurrency(MSFlexGrid1.TextMatrix(i, 7) - a(3), 2)
    End If
    MSFlexGrid1.TextMatrix(i, 9) = FormatCurrency((MSFlexGrid1.TextMatrix(i, 7) * MSFlexGrid1.TextMatrix(i, 8)) / 100)
    Next
    
    For i = mscount To MSFlexGrid1.Rows - 1
    les = les + FormatCurrency(removebraket(MSFlexGrid1.TextMatrix(i, 9)), 2)
    Text2 = CLng(Text2) + FormatCurrency(removebraket(MSFlexGrid1.TextMatrix(i, 9)), 2)
    totcol = totcol + FormatCurrency(MSFlexGrid1.TextMatrix(i, 7), 2)
    Next
    
    Text2 = FormatCurrency(Text2, 2)
    If lesup And les > 0 Then
    les = les + bm
    Set rs10 = New Recordset
    rs10.CursorLocation = adUseServer
    rs10.CursorType = adOpenKeyset
    rs10.LockType = adLockOptimistic
    rs10.Open "Select Less from Salary where CodeNo='" & cbemp.Text & "'", c
    If les < 100 Then
    If checktds Then
    rs10.Fields("Less") = les
    rs10.Update
    End If
    Else
    rs10!Less = 0
    rs10.Update
    End If
    rs10.Close
    Call fortds
    End If
    End If
    r1.Close
    Command3.SetFocus
    
 End If
    
Else
MsgBox "Select Month & Employee Code No."
End If
If mbool = True Then
    mbool = False
    branch = "karaikudi"
    mscount = MSFlexGrid1.Rows
    Call database
    Command1_Click
End If
mbool = True
Command1.Enabled = False
End Sub

Private Sub Command2_Click()
Call tds_statement_print
End Sub

Private Sub Command3_Click()
lesup = True
mbool = True
branch = ""
mscount = 1
RichTextBox2.Text = Text1.Text & " " & Switch(Text1.Text = "Jan" Or Text1.Text = "Mar" Or Text1.Text = "Feb", Mid(Combo1.Text, 6, 4), 1, Mid(Combo1.Text, 1, 4))
RichTextBox2.saveFile (App.Path & "\Statement.mkp")
Call Command1_Click
Call printing
lesup = False
inc = 0
End Sub
Private Sub Command4_Click()
Dim mo As String
inc = 0
lesup = True
RichTextBox2.Text = Text1.Text & " " & Switch(Text1.Text = "Jan" Or Text1.Text = "Mar" Or Text1.Text = "Feb", Mid(Combo1.Text, 6, 4), 1, Mid(Combo1.Text, 1, 4))
RichTextBox2.saveFile (App.Path & "\Statement.mkp")
'cbdes.Text = cbdes.List(0)
cbemp.Text = cbemp.List(0)
mo = Text1.Text
'For i = 1 To cbdes.ListCount
For j = 1 To cbemp.ListCount
Text1.Text = mo
cbemp.Text = cbemp.List(j - 1)
branch = ""
mscount = 1
mbool = True
Call Command1_Click
Call printing
Next
'cbdes.Text = cbdes.List(i)
'Call cbdes_Click
'Next
lesup = False
'Combo1.Text = "--Select Year--"
End Sub
Private Sub Command7_Click()
Call statement_print(Command7.Caption)
End Sub

Private Sub Command8_Click()
RichTextBox2.Text = ""
RichTextBox2.saveFile (App.Path & "\Statement.mkp")
inc = 0
Unload Me
End Sub
Private Sub Form_Load()
Dim i As Integer
Combo1.Clear
If Format(Now, "m") > 3 Then
Combo1.AddItem (Year(Now) & "-" & Year(Now) + 1)
var = Combo1.List(0)
Else
Combo1.AddItem (Year(Now) - 1 & "-" & Year(Now))
var = Combo1.List(0)
End If
While (Dir(App.Path & "\" & (Year(Now) - (i + 1)) & "-" & (Year(Now) - i), vbDirectory)) <> ""
Combo1.AddItem (Dir(App.Path & "\" & (Year(Now) - (i + 1)) & "-" & (Year(Now) - i), vbDirectory))
i = i + 1
Wend
Frame1.Enabled = False
MSFlexGrid1.Cols = 10
MSFlexGrid1.Rows = 2
MSFlexGrid1.FixedRows = 1
MSFlexGrid1.FixedCols = 0
MSFlexGrid1.ColWidth(0) = 700
MSFlexGrid1.ColWidth(1) = 3000
MSFlexGrid1.ColWidth(2) = 1500
MSFlexGrid1.ColWidth(3) = 1500
MSFlexGrid1.ColWidth(4) = 1500
MSFlexGrid1.ColWidth(5) = 800
MSFlexGrid1.ColWidth(6) = 1000
MSFlexGrid1.ColWidth(7) = 1500
MSFlexGrid1.ColWidth(8) = 1000
MSFlexGrid1.ColWidth(9) = 1800
MSFlexGrid1.RightToLeft = True
MSFlexGrid1.TextMatrix(0, 0) = "S.No"
MSFlexGrid1.TextMatrix(0, 1) = "Name"
MSFlexGrid1.TextMatrix(0, 2) = "Code"
MSFlexGrid1.TextMatrix(0, 3) = "Position"
MSFlexGrid1.TextMatrix(0, 4) = "IntroNo"
MSFlexGrid1.TextMatrix(0, 5) = "Rank"
MSFlexGrid1.TextMatrix(0, 6) = "Year"
MSFlexGrid1.TextMatrix(0, 7) = "Collection"
MSFlexGrid1.TextMatrix(0, 8) = "%Age"
MSFlexGrid1.TextMatrix(0, 9) = "Commission"
'cbdes.AddItem ("CED")
'cbdes.AddItem ("DA-III")
'cbdes.AddItem ("DA-II")
'cbdes.AddItem ("DA-I")
'cbdes.AddItem ("DA")
'cbdes.AddItem ("RDM")
'cbdes.AddItem ("ADM")
'cbdes.AddItem ("DM")
Label1.Caption = ""
Label6.Caption = ""
lesup = False
RichTextBox1.LoadFile (App.Path & "\salprin.mkp")
hideReport = 0
mbool = True
branch = ""
End Sub
Private Sub database()
mon(12) = "Dec"
mon(1) = "Jan"
mon(2) = "Feb"
mon(3) = "Mar"
mon(4) = "Apr"
mon(5) = "May"
mon(6) = "Jun"
mon(7) = "Jul"
mon(8) = "Aug"
mon(9) = "Sep"
mon(10) = "Oct"
mon(11) = "Nov"
Set c = New Connection
c.Provider = "Microsoft.Jet.OLEDB.4.0"
If Combo1.Text = var Then
    If branch = "" Then
        c.Open App.Path & "\jeevan.mdb"
    Else
        c.Open App.Path & "\" & branch & "\jeevan.mdb"
    End If
Else
    If branch = "" Then
        c.Open App.Path & "\" & Combo1.Text & "\jeevan.mdb"
    Else
        c.Open App.Path & "\" & Combo1.Text & "\" & branch & "\jeevan.mdb"
    End If
End If
Set r = New Recordset
r.CursorLocation = adUseServer
r.CursorType = adOpenKeyset
r.LockType = adLockOptimistic
Set r1 = New Recordset
r1.CursorLocation = adUseServer
r1.CursorType = adOpenKeyset
r1.LockType = adLockOptimistic
End Sub
Private Function percen(l As Integer, str As String) As Double
Dim s, c1, cv As Integer
Dim i As Double
Dim b As Boolean
s = Val(str)
cv = Switch(cbdes = "Agent", 1, cbdes = "DM", 2, cbdes = "ADM", 3, cbdes = "RDM", 4, cbdes = "DA", 5, cbdes = "DA-I", 6, cbdes = "DA-II", 7, cbdes = "DA-III", 8, cbdes = "CED", 9)
If s = cv Then s = 0
'b = False
r.Open "select * from Commission", c
r.MoveFirst
Do While Not r.EOF
c1 = Val(r!rank)
'If s = c1 Then b = True
If (c1 > s And c1 <= cv) Then
If l = 0 Then
'If b Then
i = i + Val(r.Fields(1))
ElseIf l = 1 Then
'If b Then
i = i + Val(r.Fields(2))
ElseIf l = 2 Then
'If b Then
i = i + Val(r.Fields(3))
Else
'If b Then
i = i + Val(r.Fields(4))
End If
End If
If s = cv Then Exit Do
'If s = r.Fields(0) Then b = True
'If c1 = r.Fields(0) Then b = False
r.MoveNext
Loop
percen = i
r.Close
End Function
Private Function commi(l As Integer, s As String, cost As Double)
Dim com As Double
If s <> cbdes Then
If l = 0 Then
a(0) = a(0) + cost
ElseIf l = 1 Then
a(1) = a(1) + cost
ElseIf l = 2 Then
a(2) = a(2) + cost
Else
a(3) = a(3) + cost
End If
End If
'If rs1.Fields(4) = "DM" Then
'com = Switch(l = 0, (cost * i) / 100, l = 1, cost / 100, l = 2, cost / 200)
'ElseIf rs1.Fields(4) = "ADM" Then
'com = Switch(l = 0, (cost * 4) / 100, l = 1, cost / 100, l = 2, cost / 200)
'ElseIf rs1.Fields(4) = "RDM " Then
'com = Switch(l = 0, (cost * 3) / 100, l = 1, cost / 100, l = 2, cost / 200)
'ElseIf rs1.Fields(4) = "DA" Then
'com = Switch(l = 0, (cost * 2) / 100, l = 1, cost / 100, l = 2, cost / 200)
'Else
'com = Switch(l = 0, (cost * 2) / 100, l > 0, cost / 200)
'End If
'commi = com
End Function
Private Sub printing()
Dim ra, page As Integer
tds = 0
If les >= 100 Then
Set rs8 = New Recordset
rs8.CursorLocation = adUseServer
rs8.CursorType = adOpenKeyset
rs8.LockType = adLockOptimistic
rs8.Open "Select PAN from AgentInfo where CodeNo='" & cbemp.Text & "'", c
Printer.CurrentX = 18
Printer.CurrentY = 20.5
If s = "yes" Then
If Len(rs8.Fields(0)) = 10 Then
tds = FormatCurrency((les * 10) / 100, 2)
'Else
'tds = FormatCurrency((les * 20) / 100, 2)
End If
End If
rs8.Close
Set pg = New Recordset
pg.CursorLocation = adUseServer
pg.CursorType = adOpenKeyset
pg.LockType = adLockOptimistic
pg.Open "Select Pos from AgentInfo where CodeNo='" & cbemp.Text & "'", c
mfaamt = mfa(Val(les), pg.Fields(0))
If hideReport = 0 Then
Printer.ScaleMode = vbCentimeters
Printer.Font = "MS Script"
page = 1
Call salaryHeader(page)
Printer.CurrentY = 8#
Y = Printer.CurrentY
If bm > 0 Then
Printer.CurrentX = 5
Printer.CurrentY = Y + 0.3
Printer.Print "Previous Month(s) Balance"
Printer.CurrentX = 18
Printer.CurrentY = Y + 0.3
Printer.Print FormatCurrency(bm, 2)
End If
Y = Printer.CurrentY
For i = 1 To MSFlexGrid1.Rows - 1
If MSFlexGrid1.TextMatrix(i, 9) <> 0 Then
'agency code
Printer.CurrentY = Y + 0.3
Printer.CurrentX = 0.5
Printer.Print MSFlexGrid1.TextMatrix(i, 2)
'rank
Printer.CurrentY = Y + 0.3
Printer.CurrentX = 3.2
Printer.Print MSFlexGrid1.TextMatrix(i, 5)
'business type
Printer.CurrentY = Y + 0.3
Printer.CurrentX = 5#
Printer.Print Switch(MSFlexGrid1.TextMatrix(i, 6) = "Lump Sum", "Plan-B,D", 1, "Recurring-A,C")
'year
Printer.CurrentY = Y + 0.3
Printer.CurrentX = 10
Printer.Print MSFlexGrid1.TextMatrix(i, 6)
'collection
Printer.RightToLeft = False
Printer.CurrentY = Y + 0.3
Printer.CurrentX = 13#
Printer.Print FormatCurrency(removebraket(MSFlexGrid1.TextMatrix(i, 7)), 2)
'%age
Printer.CurrentY = Y + 0.3
Printer.CurrentX = 15.6
Printer.Print MSFlexGrid1.TextMatrix(i, 8)
'commission
Printer.RightToLeft = True
Printer.CurrentY = Y + 0.3
Printer.CurrentX = 18
Printer.Print FormatCurrency(removebraket(MSFlexGrid1.TextMatrix(i, 9)), 2)
Y = Printer.CurrentY
If (i Mod 15) = 0 Then
Printer.NewPage
page = page + 1
Call salaryHeader(page)
Printer.CurrentY = 8#
Y = Printer.CurrentY
End If
End If
Next
'total
Printer.CurrentX = 13#
Printer.CurrentY = 19.4
Printer.Print FormatCurrency(totcol, 2)
'gross commission
Printer.CurrentX = 18
Printer.CurrentY = 19.4
Printer.Print FormatCurrency(les, 2)
'tds
Printer.Print FormatCurrency(tds, 2)
'net commission
Printer.CurrentX = 17#
Printer.CurrentY = 21.7
Printer.Print FormatCurrency(les - tds, 2)
'mfa
Printer.CurrentX = 17#
Printer.CurrentY = 22.5
Printer.Print FormatCurrency(mfaamt, 2)
'total voucher amt
Printer.CurrentX = 17#
Printer.CurrentY = 26.7
Printer.Print FormatCurrency((les - tds) + mfaamt, 2) & "/-"
'amount in words
Printer.CurrentX = 3#
Printer.CurrentY = 27.4
aw = CLng((les - tds) + mfaamt)
Printer.Print convert(aw) & "Only."
RichTextBox1.Text = str(Val(RichTextBox1.Text) + 1)
RichTextBox1.saveFile (App.Path & "\salprin.mkp")
Printer.EndDoc
End If
End If
If les > 0 And totcol > 0 Then
Call names
ra = Switch(cbdes = "DM", 2, cbdes = "ADM", 3, cbdes = "RDM", 4, cbdes = "DA", 5, cbdes = "DA-I", 6, cbdes = "DA-II", 7, cbdes = "DA-III", 8, cbdes = "CED", 9)
Call statement(cbemp.Text, rs!Name, ra, Round(les, 2), Round(tds, 2), Round(mfaamt, 2), 0, Round((les + mfaamt) - tds, 2), totcol)
rs.Close
rs3.Close
End If
End Sub

Private Function salaryHeader(ByVal pag As Integer)
Printer.Font = "MS Script"
'payable
Printer.CurrentY = 3
Printer.CurrentX = 3.5

'MsgBox Mid(cbemp.Text, 1, 4)
If Mid(cbemp.Text, 1, 4) = "0452" Then
Printer.Print "MADURAI"
Else
Printer.Print "Karaikudi"
End If

'voucher no
Printer.CurrentY = 3.8
Printer.CurrentX = 3.5
Printer.Print Val(RichTextBox1.Text)
'Printer.CurrentY = 5.5
'Printer.CurrentX = 5.5
'Printer.Print cbemp.Text
Printer.CurrentY = 4.5
Printer.CurrentX = 3.5
Call names
'employee name
Printer.Print Space(1); rs!Name
'introducer name
Printer.CurrentY = 5.5
Printer.CurrentX = 3.5
Printer.Print Space(1); rs3!Name
'month
Printer.CurrentY = 3
Printer.CurrentX = 12
Printer.Print Text1.Text & " " & Switch(Text1.Text = "Jan" Or Text1.Text = "Mar" Or Text1.Text = "Feb", Mid(Combo1.Text, 6, 4), 1, Mid(Combo1.Text, 1, 4))

Printer.CurrentX = 17
Printer.CurrentY = 3
Printer.Print "Page : "; pag
'issued on
Printer.CurrentY = 3.8
Printer.CurrentX = 12
Printer.Print Format(Now, "dd/mm/yyyy")
'codeno
Printer.CurrentY = 4.5
Printer.CurrentX = 12
Printer.Print rs!CodeNo
'introducer code
Printer.CurrentY = 5.5
Printer.CurrentX = 12
Printer.Print rs3!CodeNo
'rank
Printer.CurrentY = 4.5
Printer.CurrentX = 18
Printer.Print Switch(rs!Pos = "DM", 2, rs!Pos = "ADM", 3, rs!Pos = "RDM", 4, rs!Pos = "DA", 5, rs!Pos = "DA-I", 6, rs!Pos = "DA-II", 7, rs!Pos = "DA-III", 8, rs!Pos = "CED", 9)
'introducer rank
Printer.CurrentY = 5.5
Printer.CurrentX = 18
Printer.Print Switch(rs3!Pos = "DM", 2, rs3!Pos = "ADM", 3, rs3!Pos = "RDM", 4, rs3!Pos = "DA", 5, rs3!Pos = "DA-I", 6, rs3!Pos = "DA-II", 7, rs3!Pos = "DA-III", 8, rs3!Pos = "CED", 9)
'chain
Call senior(cbemp.Text)
End Function

Private Function names()
Set rs = New Recordset
rs.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open "Select * from AgentInfo where CodeNo='" & cbemp.Text & "'", c
Set rs3 = New Recordset
rs3.CursorLocation = adUseServer
rs3.CursorType = adOpenKeyset
rs3.LockType = adLockOptimistic
rs3.Open "Select Name,CodeNo,Pos from AgentInfo where CodeNo='" & rs!INTRONO & "'", c
End Function

Private Function mfa(t As Double, no As String) As Double
Dim l As Double
If no = "DM" Then
l = Switch(t >= 400, (t * 45) / 100, t < 400, 0)
l = Switch(l >= 1500, 1500, l < 1500, l)
ElseIf no = "ADM" Then
l = Switch(t >= 1000, (t * 40) / 100, t < 1000, 0)
l = Switch(l >= 2000, 2000, l < 2000, l)
ElseIf no = "RDM" Then
l = Switch(t >= 1500, (t * 35) / 100, t < 1500, 0)
l = Switch(l >= 3000, 3000, l < 3000, l)
ElseIf no = "DA" Then
l = Switch(t >= 2500, (t * 30) / 100, t < 2500, 0)
l = Switch(l >= 4000, 4000, l < 4000, l)
ElseIf no = "DA-I" Then
l = Switch(t >= 4000, (t * 25) / 100, t < 4000, 0)
l = Switch(l >= 5000, 5000, l < 5000, l)
Else
l = Round(0#)
End If
mfa = l
End Function
Private Sub fortds()
Set rs4 = New Recordset
rs4.CursorLocation = adUseServer
rs4.CursorType = adOpenKeyset
rs4.LockType = adLockOptimistic
rs4.Open "Select * from salary where CodeNo='" & cbemp.Text & "'", c
If checktds Or IsNull(rs4!Tdsmonth) Then
If IsNull(rs4!tds) Then rs4!tds = 0
'If Val(rs4!tds) < 2500 Then
rs4!tds = Val(rs4!tds) + FormatCurrency(Text2, 2)
rs4!Tdsmonth = Switch(IsNull(rs4!Tdsmonth), "", 1, rs4!Tdsmonth) + Switch(Text1.Text = "Jun", UCase(Mid(Text1.Text, 2, 1)), Text1.Text = "Jul", UCase(Mid(Text1.Text, 3, 1)), 1, UCase(Mid(Text1.Text, 1, 1)))
'End If
rs4.Update
End If
If Val(rs4!tds) >= 2500 Then
s = "yes"
Else
s = "no"
End If
rs4.Close
End Sub
Private Function checktds() As Boolean
Dim s As String
Dim bo As Boolean
Dim tm As Integer
Set rs9 = New Recordset
rs9.CursorLocation = adUseServer
rs9.CursorType = adOpenKeyset
rs9.LockType = adLockOptimistic
'MsgBox (c)
rs9.Open "Select Tdsmonth from salary where CodeNo='" & cbemp.Text & "'", c
bo = True
s = Switch(Text1.Text = "Jun", "U", Text1.Text = "Jul", "L", Text1.Text = "Mar", "R", Text1.Text = "Aug", "G", 1, Mid(Text1.Text, 1, 1))
tm = Switch(IsNull(rs9!Tdsmonth), 0, 1, Len(rs9!Tdsmonth))
For i = 1 To tm
If s = Mid(rs9!Tdsmonth, i, 1) Then
bo = False
End If
Next
rs9.Close
checktds = bo
End Function
Private Sub senior(st As String)
Dim s(100), t(100) As String
Dim i, j, l As Integer
Set dbne = New Connection
dbne.Provider = "Microsoft.Jet.OLEDB.4.0"
If branch = "" Then
        dbne.Open App.Path & "\jeevan.mdb"
    Else
        dbne.Open App.Path & "\" & branch & "\jeevan.mdb"
    End If
'dbne.Open App.Path & "\Jeevan.mdb"
Set rs = New Recordset
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.Open "select IntroNo, Pos from AgentInfo where CodeNo='" & st & "' and Pos<>'CED' and Pos<>'LEFT'", dbne
If rs.Fields(1) <> "CED" Then
Do
If j = 0 Then
While Not rs.EOF
s(l) = rs.Fields(0)
t(l) = rs.Fields(1)
l = l + 1
j = l
rs.MoveNext
Wend
End If
Set rs1 = New Recordset
rs1.LockType = adLockOptimistic
rs1.CursorLocation = adUseServer
rs1.CursorType = adOpenKeyset
rs1.Open "select IntroNo from AgentInfo where CodeNo='" & s(i) & "' and Pos<>'CED' and Pos<>'LEFT'", dbne
While Not rs1.EOF
s(j) = rs1.Fields(0)
j = j + 1
rs1.MoveNext
Wend
i = i + 1
Loop While i < j
End If
Set rs = New Recordset
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.Open "select * from AgentInfo where CodeNo='" & st & "'", dbne
X = 2
For i = 0 To j - 1
If t(i) <> "LEFT" Then
Set rs = New Recordset
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.Open "select * from AgentInfo where CodeNo='" & s(i) & "'", dbne
Printer.CurrentY = 6.5
Printer.CurrentX = X
Printer.Print s(i) & "-" & rs.Fields(1)
X = X + (Len(s(i) & "-" & rs.Fields(1)) / 5)
End If
Next i
End Sub
Private Sub statement(ByVal cod As String, ByVal nam As String, ByVal rs As Integer, ByVal com As Double, ByVal td As Double, ByVal mf As Double, ByVal ad As Integer, ByVal t As Double, ByVal totcol As Double)
RichTextBox2.Text = RichTextBox2.Text & cod & "|" & nam & "|" & rs & "|" & com & "|" & td & "|" & mf & "|" & ad & "|" & t & "|" & totcol & "|"
RichTextBox2.saveFile (App.Path & "\Statement.mkp")
End Sub
Private Sub statement_print(ByVal e As String)
Dim page As Integer
If Text1.Text <> "" Then
Call statement1
page = 1
reportHeader (page)
j = 0
If e = "Generate Report" Then
k = 0
Else
k = 6
End If

pagerep = 1

For i = 0 To inc - 1 Step 9
If (k = 6 And st1(i + 4) > 0) Or e = "Generate Report" Then
Printer.CurrentX = 0.5
Y = Printer.CurrentY
Printer.CurrentY = Y
'sno
j = j + 1
Printer.Print (j)

'codeno
Printer.CurrentX = 1.5
Printer.CurrentY = Y
Printer.Print st1(i)

'name
Printer.CurrentY = Y
Printer.CurrentX = 3.5
Printer.Print st1(i + 1)

'rank
Printer.CurrentY = Y
Printer.CurrentX = 7.5
Printer.Print st1(i + 2)

'collection
Printer.CurrentY = Y
Printer.CurrentX = 8.3
Printer.Print FormatCurrency(st1(i + 8), 2)

'commission
Printer.CurrentY = Y
Printer.CurrentX = 10.5
Printer.Print FormatCurrency(st1(i + 3), 2)

'tds
Printer.CurrentY = Y
Printer.CurrentX = 13
Printer.Print FormatCurrency(st1(i + 4), 2)

'mfa
Printer.CurrentY = Y
Printer.CurrentX = 15
Printer.Print FormatCurrency(st1(i + 5), 2)

'adv
Printer.CurrentY = Y
Printer.CurrentX = 17
Printer.Print FormatCurrency(st1(i + 6), 2)

'amt
Printer.CurrentY = Y
Printer.CurrentX = 19
Printer.Print FormatCurrency(st1(i + 7), 2)
Printer.Print
If Printer.CurrentY > 25 Then Printer.NewPage
    coltot = coltot + Val(st1(i + 8))
    comtot = comtot + Val(st1(i + 3))
    tdstot = tdstot + Val(st1(i + 4))
    mfatot = mfatot + Val(st1(i + 5))
    advtot = advtot + Val(st1(i + 6))
    total = total + Val(st1(i + 7))
End If

pagerep = pagerep + 1

If (pagerep Mod 20) = 0 Then
Printer.NewPage
page = page + 1
reportHeader (page)
End If
Next
Printer.Print "__________________________________________________________________________________________________________________________________________"
Printer.Print
Y = Printer.CurrentY
'Printer.CurrentX = 1.5
'Printer.CurrentY = Y
'Printer.Print "Gross Total"
'Printer.CurrentX = 8.3
'Printer.CurrentY = Y
'Printer.Print FormatCurrency(coltot, 2)
Printer.CurrentX = 10.5
Printer.CurrentY = Y
Printer.Print FormatCurrency(comtot, 2)
Printer.CurrentX = 13
Printer.CurrentY = Y
Printer.Print FormatCurrency(tdstot, 2)
Printer.CurrentX = 15
Printer.CurrentY = Y
Printer.Print FormatCurrency(mfatot, 2)
Printer.CurrentX = 17
Printer.CurrentY = Y
Printer.Print FormatCurrency(advtot, 2)
Printer.CurrentY = Y
Printer.CurrentX = 19
Printer.Print FormatCurrency(total, 2)
Printer.Print "__________________________________________________________________________________________________________________________________________"
Printer.EndDoc
inc = 0
Else
MsgBox "Please Select Month"
End If
End Sub

Private Function reportHeader(ByVal page As Integer)
Printer.ScaleMode = 7
Printer.CurrentY = 1
Printer.CurrentX = 18
Printer.Print "Page " & page
Printer.CurrentY = 2
Printer.CurrentX = 6
Printer.FontBold = True
Printer.FontSize = 14
'Printer.PaintPicture Image1, 5.3, 1.7, 0.9, 0.9
Printer.Print "Jeevan Vaisya Green AgroTech LLP"
Printer.FontBold = False
Printer.FontSize = 10
Printer.CurrentX = 5
Printer.Print "Regd. off: A-46, Suburaman Street West, Gandhiji Main Road,"
Printer.CurrentX = 7
Printer.Print "Thirunagar 1st Stop, Madurai - 625006."
Printer.CurrentX = 8
Printer.Print "Ph: 0452-4367415,4367416."
Printer.Print
Printer.Print
Printer.CurrentX = 8
If e = "Generate Report" Then
Printer.Print repmon & " ORC Statement"
Else
Printer.Print repmon & " TDS Report"
End If
Printer.FontSize = 9
Printer.CurrentY = 5
Printer.CurrentX = 16
Printer.Print "Date: " & datechange(Now)
Printer.Print "_______________________________________________________________________________________________________________________________________________________________________________________________________________"
'1
Printer.CurrentY = 6
Printer.CurrentX = 0.5
'2
X = Printer.CurrentX
Printer.Print "S.No."
Printer.CurrentY = 6
Printer.CurrentX = 1.5
'6
X = Printer.CurrentX
Printer.Print "Code No."
Printer.CurrentY = 6
Printer.CurrentX = 4.5
'9
Printer.Print "Name"
Printer.CurrentY = 6
Printer.CurrentX = 7.3
Printer.Print "Rank"
'12

Printer.CurrentY = 6
Printer.CurrentX = 8.5
Printer.Print "Collection"

Printer.CurrentY = 6
Printer.CurrentX = 10.5
Printer.Print "Commission"
'14
Printer.CurrentY = 6
Printer.CurrentX = 13
Printer.Print "TDS"
'15
Printer.CurrentY = 6
Printer.CurrentX = 15.5
Printer.Print "MFA"
'18
Printer.CurrentY = 6
Printer.CurrentX = 17.5
X = Printer.CurrentX
Printer.Print "Adv"
'20
Printer.CurrentY = 6
Printer.CurrentX = 19.3
X = Printer.CurrentX
Printer.Print "Amount"
Printer.Print "_______________________________________________________________________________________________________________________________________________________________________________________________________________"
Printer.Print
End Function


Private Sub statement1()
Dim st As String
hideReport = 1
branch = ""
mscount = 1
Call Command4_Click
RichTextBox2.LoadFile (App.Path & "\Statement.mkp")
l = Len(RichTextBox2.Text)
j = 0
repmon = Mid(RichTextBox2.Text, 1, 8)
For i = 9 To l
If Mid(RichTextBox2.Text, i, 1) = "|" Then inc = inc + 1
Next i
ReDim st1(inc) As Variant
For i = 9 To l
If Mid(RichTextBox2.Text, i, 1) <> "|" Then
st = st + Mid(RichTextBox2.Text, i, 1)
Else
st1(j) = st
st = ""
j = j + 1
End If
Next i
hideReport = 0
End Sub
Private Function designation(ByVal s As String)
Set r10 = New Recordset
r10.CursorLocation = adUseServer
r10.CursorType = adOpenKeyset
r10.LockType = adLockOptimistic
r10.Open "Select Pos, Name from AgentInfo where CodeNo='" & s & "'", c
Label1.Caption = "NAME: " & r10!Name
Label6.Caption = "DESIGNATION: " & r10!Pos
designation = r10!Pos
End Function

Private Function tds_statement_print()
Dim trs As Recordset
If Text1.Text <> "" Then
Call statement1
Set trs = New Recordset
trs.CursorLocation = adUseServer
trs.CursorType = adOpenKeyset
trs.LockType = adLockOptimistic
If st1(0) <> "" Then
Printer.ScaleMode = 7
Printer.CurrentY = 2
Printer.CurrentX = 6
Printer.FontBold = True
Printer.FontSize = 14
'Printer.PaintPicture Image1, 5.3, 1.7, 0.9, 0.9
Printer.Print "Jeevan Vaisya Green AgroTech LLP"
Printer.FontBold = False
Printer.FontSize = 10
Printer.CurrentX = 5
Printer.Print "Regd. off: A-46, Suburaman Street West, Gandhiji Main Road,"
Printer.CurrentX = 7
Printer.Print "Thirunagar 1st Stop, Madurai - 625006."
Printer.CurrentX = 8
Printer.Print "Ph: 0452-4367415,4367416."
Printer.Print
Printer.Print
Printer.CurrentX = 8
Printer.Print repmon & " TDS Report"
Printer.FontSize = 9
Printer.CurrentY = 5
Printer.CurrentX = 16
Printer.Print "Date: " & datechange(Now)
Printer.Print "_______________________________________________________________________________________________________________________________________________________________________________________________________________"
'1
Printer.CurrentY = 6
Printer.CurrentX = 0.5
'2
X = Printer.CurrentX
Printer.Print "S.No."
Printer.CurrentY = 6
Printer.CurrentX = 1.5
'6
X = Printer.CurrentX
Printer.Print "Code No."
Printer.CurrentY = 6
Printer.CurrentX = 4.5
'9
Printer.Print "Name"
Printer.CurrentY = 6
Printer.CurrentX = 9.5
Printer.Print "PAN No."
'12

Printer.CurrentY = 6
Printer.CurrentX = 13.8
Printer.Print "Commission"
'14
Printer.CurrentY = 6
Printer.CurrentX = 16.7
Printer.Print "TDS (10%)"
'Printer.CurrentY = 6.3
'Printer.CurrentX = 15
'Printer.Print "______________________"

'20
'Printer.CurrentY = 6.5
'Printer.CurrentX = 18
'X = Printer.CurrentX
'Printer.Print "Total Amount"
'Printer.CurrentY = 7
'Y = Printer.CurrentY
'Printer.CurrentX = 15
'Printer.Print "10%"
'Printer.CurrentY = Y
'Printer.CurrentX = 18.3
'Printer.Print "20%"
Printer.Print "_______________________________________________________________________________________________________________________________________________________________________________________________________________"
Printer.Print
j = 0
For i = 0 To inc - 1 Step 9
If st1(i + 4) > 0 Then
trs.Open "Select * from AgentInfo where CodeNo='" & st1(i) & "'", c
If Len(trs!PAN) = 10 Then
Printer.CurrentX = 0.5
Y = Printer.CurrentY
Printer.CurrentY = Y
'sno
j = j + 1
Printer.Print (j)

'codeno
Printer.CurrentX = 1.5
Printer.CurrentY = Y
Printer.Print st1(i)

'name & address
Printer.CurrentY = Y
Printer.CurrentX = 3.5
Printer.Print st1(i + 1)

'Pan No
Printer.CurrentY = Y
Printer.CurrentX = 9.3
Printer.Print trs!PAN


'commission
Printer.CurrentY = Y
Printer.CurrentX = 14
Printer.Print FormatCurrency(st1(i + 3), 2)

'tds
Printer.CurrentY = Y
If Len(trs!PAN) = 10 Then
Printer.CurrentX = 16.7
comtot = comtot + Val(st1(i + 4))
Else
Printer.CurrentX = 18.4
total = total + Val(st1(i + 4))
End If
Printer.Print FormatCurrency(st1(i + 4), 2)

'Call address(trs!address)
'For Each k In ad
'If k <> "" Then
'Printer.CurrentX = 3.5
'Printer.Print k
'End If
'Next k
Printer.Print
tdstot = tdstot + Val(st1(i + 4))
End If
trs.Close
If Printer.CurrentY > 27.5 Then Printer.NewPage
End If
Next
Printer.Print "__________________________________________________________________________________________________________________________________________"
Printer.Print
Y = Printer.CurrentY
'Printer.CurrentX = 11.5
'Printer.CurrentY = Y
'Printer.Print "Total: (% wise) "
'Printer.CurrentX = 14.7
'Printer.CurrentY = Y
'Printer.Print FormatCurrency(comtot, 2)
'Printer.CurrentY = Y
'Printer.CurrentX = 18.4
'Printer.Print FormatCurrency(total, 2)
'Printer.Print
'Y = Printer.CurrentY
Printer.CurrentY = Y
Printer.CurrentX = 14.7
Printer.Print "Total: "
Printer.CurrentY = Y
Printer.CurrentX = 18.4
Printer.Print FormatCurrency(tdstot, 2)
Printer.Print "__________________________________________________________________________________________________________________________________________"
Printer.EndDoc
inc = 0
End If
Else
MsgBox "Please Select Month"
End If
End Function

Private Function address(X As String) As Integer
j = 0
ad(0) = ""
For i = 1 To Len(X)
If AscW(Mid(X, i, 1)) <> 13 Then
ad(j) = ad(j) + Mid(X, i, 1)
Else
j = j + 1
ad(j) = ""
i = i + 1
End If
Next i
address = j
End Function

Private Sub Text1_Click()
    branch = ""
    mscount = 1
    Command1.Enabled = True
End Sub

Private Function removebraket(s As String) As String
Dim rep As String
 rep = s
 rep = Replace(rep, "(", "")
 rep = Replace(rep, ")", "")
 removebraket = rep
End Function
